package fightplan.actions;

import java.awt.event.ActionEvent;
import java.io.IOException;

import javax.swing.AbstractAction;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;

import fightplan.FightPlan;

@SuppressWarnings("serial")
public class HelpAction extends AbstractAction {

	private JFrame frame;

	public HelpAction(JFrame frame) {
		super("Hilfe");
		this.frame = frame;
	}

	public void actionPerformed(ActionEvent actionEvent) {
		try {
			JEditorPane pane = new JEditorPane(FightPlan.class.getResource("docs/help.html"));
			pane.setEditable(false);
			JDialog dialog = new JDialog(frame, "Hilfe");
			dialog.setSize(500, 600);
			dialog.setLocationRelativeTo(null);
			dialog.getContentPane().add(new JScrollPane(pane));
			dialog.setVisible(true);
		} catch (IOException e) {
			JOptionPane.showMessageDialog(frame, "Hilfe kann nicht angezeigt werden.");
			e.printStackTrace();
		}
	}

}